function Node(val) {
  this.value = val;
  this.left = null;
  this.right = null;
}

let a = new Node('a');
let b = new Node('b');
let c = new Node('c');
let d = new Node('d');
let e = new Node('e');
let f = new Node('f');
let g = new Node('g');

a.left = b;
a.right = c;
b.left = d;
b.right = e;
c.left = f;
c.right = g;

function scopeSearch(arr, traget) {

  if (arr == null || arr.length == 0) return false;
  let lineArr = []
  for (let i = 0; i < arr.length; i++) {
    if (arr[i] != null && arr[i].value == traget) return true;
    lineArr.push(arr[i].left)
    lineArr.push(arr[i].right)
  }
  if (lineArr[lineArr.length - 1] == null) return false;
  return scopeSearch(lineArr, traget);
}

console.log(scopeSearch([a], 'f'));
